package com.tjetc.view.impl;

import com.tjetc.pojo.dto.RoomDTO;
import com.tjetc.utils.ScannerUtils;
import com.tjetc.view.RoomCRUDPage;

/**
 * @Author: itda
 * @Date: 2024/5/10 18:11
 * @Description: RoomCRUDImpl
 */
public class RoomCRUDPageImpl implements RoomCRUDPage {
    @Override
    public RoomDTO save() {
        System.out.println("请输入所属酒店id:");
        Long hotelid = ScannerUtils.sc.nextLong();
        System.out.println("请输入房间类型:");
        String roomType = ScannerUtils.sc.next();
        System.out.println("请输入房间价格:");
        Double roomPrice = ScannerUtils.sc.nextDouble();
        System.out.println("请输入房间容量:");
        Short roomCapacity = ScannerUtils.sc.nextShort();
        System.out.println("请输入房间描述:");
        String roomDescription = ScannerUtils.sc.next();
        System.out.println("请输入房间是否可用:");
        Short roomAvailability = ScannerUtils.sc.nextShort();
        return RoomDTO.builder()
                .hotelId(hotelid)
                .type(roomType)
                .price(roomPrice)
                .capacity(roomCapacity)
                .description(roomDescription)
                .availability(roomAvailability)
                .build();
    }

    @Override
    public Long delete() {
        System.out.println("请输入要删除的房间id:");
        return ScannerUtils.sc.nextLong();
    }

    @Override
    public RoomDTO update() {
        System.out.println("请输入要修改的房间id:");
        Long roomid = ScannerUtils.sc.nextLong();
        System.out.println("请输入所属酒店id:");
        Long hotelid = ScannerUtils.sc.nextLong();
        System.out.println("请输入房间类型:");
        String roomType = ScannerUtils.sc.next();
        System.out.println("请输入房间价格:");
        Double roomPrice = ScannerUtils.sc.nextDouble();
        System.out.println("请输入房间容量:");
        Short roomCapacity = ScannerUtils.sc.nextShort();
        System.out.println("请输入房间描述:");
        String roomDescription = ScannerUtils.sc.next();
        System.out.println("请输入房间是否可用:");
        Short roomAvailability = ScannerUtils.sc.nextShort();
        return RoomDTO.builder()
                .id(roomid)
                .hotelId(hotelid)
                .type(roomType)
                .price(roomPrice)
                .capacity(roomCapacity)
                .description(roomDescription)
                .availability(roomAvailability)
                .build();
    }
}
